#ifndef QP_QF_PK_HPP
#define QP_QF_PK_HPP
#include <vector>
#include "QFPort.hpp"

#ifndef QP_QPSET_HPP
#include "QPSet.hpp"
#endif

namespace QP {

#ifndef QF_CRIT_STAT_TYPE
/// \brief This is an internal macro for defining the critical section
/// status type.
///
/// The purpose of this macro is to enable writing the same code for the
/// case when critical section status type is defined and when it is not.
/// If the macro #QF_CRIT_STAT_TYPE is defined, this internal macro
/// provides the definition of the critical section status variable.
/// Otherwise this macro is empty.
/// \sa #QF_CRIT_STAT_TYPE
///
#define QF_CRIT_STAT_

/// \brief This is an internal macro for entering a critical section.
///
/// The purpose of this macro is to enable writing the same code for the
/// case when critical section status type is defined and when it is not.
/// If the macro #QF_CRIT_STAT_TYPE is defined, this internal macro
/// invokes #QF_CRIT_ENTRY passing the key variable as the parameter.
/// Otherwise #QF_CRIT_ENTRY is invoked with a dummy parameter.
/// \sa #QF_CRIT_ENTRY
///
#define QF_CRIT_ENTRY_() QF_CRIT_ENTRY(dummy)

/// \brief This is an internal macro for exiting a critical section.
///
/// The purpose of this macro is to enable writing the same code for the
/// case when critical section status type is defined and when it is not.
/// If the macro #QF_CRIT_STAT_TYPE is defined, this internal macro
/// invokes #QF_CRIT_EXIT passing the key variable as the parameter.
/// Otherwise #QF_CRIT_EXIT is invoked with a dummy parameter.
/// \sa #QF_CRIT_EXIT
///
#define QF_CRIT_EXIT_() QF_CRIT_EXIT(dummy)

#else
#define QF_CRIT_STAT_ QF_CRIT_STAT_TYPE critStat_;
#define QF_CRIT_ENTRY_() QF_CRIT_ENTRY(critStat_)
#define QF_CRIT_EXIT_() QF_CRIT_EXIT(critStat_)
#endif

// package-scope objects -----------------------------------------------------
extern std::vector<std::shared_ptr<QTimeEvt>> QF_timeEvtListHead_;
extern QSubscrList *QF_subscrList_;  ///< the subscriber list array
extern int QF_maxSignal_;            ///< the maximum published signal
}

/// \brief access element at index \a i_ from the base pointer \a base_
#define QF_PTR_AT_(base_, i_) (base_[i_])
#endif  // QP_QF_PK_HPP
